package com.twschool.practice;

public class Position {
    private int x;
    private int y;
    private Direction direction;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }


    public void move() {
        switch (direction){
            case N:
                this.setY(this.getY()+1);
                break;
            case S :
                this.setY(this.getY()-1);
                break;
            case W:
                this.setX(this.getX()-1);
                break;
            case E:
                this.setX(this.getX()+1);
                break;
        }
    }

    public void turnLeft(){
        this.setDirection(direction.leftTurn());
    }


    public void turnRight(){
        this.setDirection(direction.rightTurn());
    }

    public Direction getDirection() {
        return direction;
    }

    public void setDirection(Direction direction) {
        this.direction = direction;
    }
}
